package br.com.mucceli.politicapopular.model;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author mucceli
 */
@Entity
@Table(name = "POLITICO_ESCANDALO")
@NamedQueries({
    @NamedQuery(name = "PoliticoEscandalo.findAll", query = "SELECT p FROM PoliticoEscandalo p"),
    @NamedQuery(name = "PoliticoEscandalo.findByFkPolitico", query = "SELECT p FROM PoliticoEscandalo p WHERE p.politicoEscandaloPK.fkPolitico = :fkPolitico"),
    @NamedQuery(name = "PoliticoEscandalo.findByFkEscandalo", query = "SELECT p FROM PoliticoEscandalo p WHERE p.politicoEscandaloPK.fkEscandalo = :fkEscandalo")})
public class PoliticoEscandalo implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PoliticoEscandaloPK politicoEscandaloPK;
    @JoinColumn(name = "FK_POLITICO", referencedColumnName = "ID_POLITICO", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Politico politico;

    public PoliticoEscandalo() {
    }

    public PoliticoEscandalo(PoliticoEscandaloPK politicoEscandaloPK) {
        this.politicoEscandaloPK = politicoEscandaloPK;
    }

    public PoliticoEscandalo(int fkPolitico, int fkEscandalo) {
        this.politicoEscandaloPK = new PoliticoEscandaloPK(fkPolitico, fkEscandalo);
    }

    public PoliticoEscandaloPK getPoliticoEscandaloPK() {
        return politicoEscandaloPK;
    }

    public void setPoliticoEscandaloPK(PoliticoEscandaloPK politicoEscandaloPK) {
        this.politicoEscandaloPK = politicoEscandaloPK;
    }

    public Politico getPolitico() {
        return politico;
    }

    public void setPolitico(Politico politico) {
        this.politico = politico;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (politicoEscandaloPK != null ? politicoEscandaloPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PoliticoEscandalo)) {
            return false;
        }
        PoliticoEscandalo other = (PoliticoEscandalo) object;
        if ((this.politicoEscandaloPK == null && other.politicoEscandaloPK != null) || (this.politicoEscandaloPK != null && !this.politicoEscandaloPK.equals(other.politicoEscandaloPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.mycompany.mavenproject1.PoliticoEscandalo[ politicoEscandaloPK=" + politicoEscandaloPK + " ]";
    }
    
}
